<template>
  <div>
    <div class="help-banner">
      <h1>猪爸爸起名平台</h1>
      <h3>帮助中心</h3>
    </div>
    <div class="container p-5 m-hide">
      <el-container>
        <el-aside width="300px" style="padding-right: 50px;">
          <el-collapse accordion class="menu-list">
            <el-collapse-item
              v-for="(item,index) in menuList"
              :key="index"
              class="el-collapse-item"
            >
              <template slot="title">
                <p class="menu-title">{{item.title}}</p>
              </template>
              <div
                class="menu-item"
                :class="sIndex==index && sIindex==iindex?'on':''"
                v-for="(iitem,iindex) in item.texts"
                :key="iindex"
                @click="menuClick(index,iindex,iitem)"
              >{{iitem.title}}</div>
            </el-collapse-item>
          </el-collapse>
        </el-aside>
        <el-main>
          <h3 class="context-title">{{content.title}}</h3>
          <p v-html="content.text" class="content-p"></p>
        </el-main>
      </el-container>
    </div>

    <div class="m-show container">
      <el-collapse v-model="activeName" accordion>
        <el-collapse-item
          :title="item.title"
          :name="index"
          v-for="(item,index) in menuList"
          :key="index"
          class="el-collapse-item"
        >
          <div
            v-for="(iitem,iindex) in item.texts"
            :key="iindex"
            class="m-menu-item"
            @click="mDetail(iitem)"
          >{{iitem.title}}</div>
        </el-collapse-item>
      </el-collapse>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menuList: [],
      sIndex: 0,
      sIindex: 0,
      content: {},
      defaultProps: {
        children: "texts",
        label: "title"
      },
      activeName: "1"
    };
  },
  created() {
    this.getInit();
  },
  methods: {
    mDetail(data) {
      data = encodeURIComponent(JSON.stringify(data));
      this.$router.push({
        path: "/help/mContent",
        query: {
          data: data
        }
      });
    },
    getTexts() {
      this.content = this.menuList[this.sIndex].texts[this.sIindex];
    },
    menuClick(i, j, data) {
      this.sIndex = i;
      this.sIindex = j;
      this.content = data;
      // this.getTexts()
    },
    getInit() {
      this.$ajax.get("/sysHelper/apiList").then(res => {
        console.log(res);
        this.menuList = res.data.data;
        this.getTexts();
      });
    }
  }
};
</script>

<style scoped>
.el-collapse-item.el-collapse-item {
  background-color: #fff !important;
}
.m-show {
  display: none;
}
@media screen and (max-width: 450px) {
  .m-menu-item {
    margin-left: 10px;
    /* line-height: 30px; */
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .m-show {
    display: block !important;
    min-height: 300px;
  }
  .m-hide {
    display: none;
  }
  .help-banner h1 {
    font-size: 42px !important;
  }
  .help-banner h3 {
    font-size: 32px !important;
    margin-top: 26px !important;
  }
  .help-banner {
    height: 150px !important;
  }
}
.content-p {
  font-size: 14px;
  font-family: SourceHanSansCN;
  font-weight: 400;
  color: rgba(132, 132, 132, 1);
  line-height: 24px;
}
.context-title {
  line-height: 1.2;
  font-size: 24px;
  font-family: SourceHanSansCN;
  font-weight: 600;
  color: rgba(103, 103, 103, 1);
  margin-bottom: 30px;
}
.menu-title {
  font-size: 18px;
  color: #b2b2b2;
  height: 35px;
  line-height: 35px;
  background-color: #fff;
}
.menu-list {
  border-left: 2px solid #ccc;
  border-top: none;
  border-bottom: none;
  padding-left: 20px;
}
.menu-item.on {
  color: #405cda;
  position: relative;
  overflow: inherit !important;
}
.menu-item:hover {
  color: #405cda;
}

.menu-item.on::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 100%;
  background-color: #405cda;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  animation: hei 300ms ease forwards;
}
@keyframes hei {
  from {
    height: 0;
  }
  to {
    height: 100%;
  }
}
.menu-item {
  height: 30px !important;
  line-height: 30px !important;
  padding-left: 15px;
  cursor: pointer;
  color: #a9b1b3;
  font-size: 14px;
  /* transform: translateX(-2px); */
}
.el-main {
  color: #333;
  line-height: 160px;
  min-height: 500px;
}
.p-5 {
  padding-top: 127px;
  padding-bottom: 127px;
}
.help-banner h3 {
  font-size: 54px;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: rgba(255, 255, 255, 1);
  margin-top: 52px;
}
.help-banner h1 {
  font-size: 60px;
  font-family: Source Han Sans CN;
  font-weight: 600;
  color: rgba(255, 255, 255, 1);
}
.help-banner {
  width: 100%;
  height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: url(../../assets/images/help-bg.png);
  background-size: cover;
  background-repeat: no-repeat;
}
</style>
